package com.sxbbc.common.core.enums;

import com.sxbbc.common.basics.utils.calculation.CalcuUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 冻结业务类型枚举类
 *
 * @author leehao
 * @date 2019-07-14
 */
public enum FreezeTypeEnums {
    ORDER_ONLINE_FREEZE(1,"订单线上支付冻结",true),
    ORDER_OFFLINE_FREEZE(2,"订单线下买单冻结",true);

    private Integer id;
    private String name;
    private Boolean valid;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getValid() {
        return valid;
    }

    public void setValid(Boolean valid) {
        this.valid = valid;
    }

    FreezeTypeEnums(Integer id, String name, Boolean valid) {
        this.id = id;
        this.name = name;
        this.valid = valid;
    }

    public static List<FreezeTypeEnums> queryList() {
        List<FreezeTypeEnums> list = new ArrayList<FreezeTypeEnums>();
        for (FreezeTypeEnums o : FreezeTypeEnums.values()) {
            if (o.getValid()) {
                list.add(o);
            }
        }
        return list;
    }

    public static String getName(Integer id) {
        String str = "";
        for (FreezeTypeEnums o : FreezeTypeEnums.values()) {
            if (CalcuUtils.getInstance().isEquals(id, o.getId())) {
                str = o.getName();
                break;
            }
        }
        return str;
    }
}
